<template>
  <div class="account_inquiry_page">
    <div class="account_info">
      <p>总资产(人民币/元) <span class="icon van-icon-bulb-o"></span> </p>
      <span>{{267484757.79 | currency('')}}</span>
    </div>
    <div class="assets">
      <div class="info">
        <div class="">
          <p>基金及理财</p>
          <span>111</span>
        </div>
        <div class="">
          <p>总负债</p>
          <span>11112</span>
        </div>
      </div>
    </div>
    <div class="assets_detail">
      <div class="assets_type">
        <van-tabs v-model="active" background="#EFEFEF"
                  color="#188CD1" title-active-color="#188CD1">
          <van-tab title="活期">
            <!--<div class="current"></div>-->
          </van-tab>
          <van-tab title="定期">
            <!--<div class="regular"></div>-->
          </van-tab>
          <van-tab title="贷款">
            <!--<div class="loan"></div>-->
          </van-tab>
        </van-tabs>
      </div>
      <div class="contentList">
        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="onLoad"
        >
          <van-cell v-for="item in list" :key="item" :title="item"
                    is-link value="111" @click="goDetail" />
        </van-list>
      </div>
    </div>
  </div>
</template>

<script>
import { Tab, Tabs, List } from 'vant';
import { queryAccountsBanlance } from '@/libs/api';

export default {
  components: {
    [Tab.name]: Tab,
    [Tabs.name]: Tabs,
    [List.name]: List
  },
  data() {
    return {
      active: 0,
      list: [],
      loading: false,
      finished: false
    };
  },
  methods: {
    goDetail(item) {
      this.$router.push('/depositSummary');
      console.log(item);
    },
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        for (let i = 0; i < 10; i += 1) {
          this.list.push(this.list.length + 1);
        }

        // 加载状态结束
        this.loading = false;

        // 数据全部加载完成
        if (this.list.length >= 30) {
          this.finished = true;
        }
      }, 1000);
    },
    initList() {
      queryAccountsBanlance(this, {
        hostNo: '04302165880',
        operNo: '1745210354',
        acNo: '',
        acctEntNoTp: 1
      }).then((res) => {
        console.log(res);
      });
    }
  },
  created() {
    this.initList();
    console.log(1);
  }
};
</script>

<style lang="less">
.account_inquiry_page {
  height: 100%;
  background-color: #EFEFEF;
  .account_info{
    color: #FFF;
    text-align: center;
    background-color: #188CD1;
    height: 5rem;
    line-height: 2rem;
    padding: 2.5rem 0;
  }
  .assets{
    width: 80vw;
    height: 4.6rem;
    background-color: #fff;
    margin-top: -2.3rem;
    margin-left: 10vw;
    border-radius: 0.25rem;
    text-align: center;
    .info {
      display: inline-flex;
      justify-content: space-around;
      padding: 1rem;
      width: calc(100% - 2rem);
      height: calc(100% - 2rem);
      line-height: 1.3rem;
      div{
        position: relative;
        width: 50%;
        span {
          font-size: 1.3rem;
          font-weight: bold;
        }
      }
      div:first-child::after{
        content: '';
        width: 3px;
        background: #999;
        position: absolute;
        height: 2rem;
        top: 5PX;
        right: 0;
      }
    }
  }
  .assets_detail{
    height: calc(100% - 12.3rem);
    background-color: #fff;
    .contentList {
      height: calc(100% - 44PX);
      overflow-y: auto;
    }
  }
}
</style>
